package cloud.daodao.storm.common.security.api;

import cloud.daodao.storm.common.security.constant.SecurityConstant;
import cloud.daodao.storm.common.constant.AppConstant;
import cloud.daodao.storm.common.model.Request;
import cloud.daodao.storm.common.model.Response;
import cloud.daodao.storm.common.security.model.rsa.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PostExchange;

/**
 * @author DaoDao
 */
@Tag(name = "RsaApi", description = "RsaApi")
@HttpExchange(url = AppConstant.API)
public interface RsaApi {

    @Operation(summary = "RSA 加密", description = "@DaoDao 输入 RSA 公钥，加密数据")
    @PostExchange(url = SecurityConstant.RSA_ENCRYPT)
    Response<RsaCipherData> rsaEncrypt(@RequestBody @Valid Request<RsaCipherParam> request);

    @Operation(summary = "RSA 解密", description = "@DaoDao 输入 RSA 私钥，解密数据")
    @PostExchange(url = SecurityConstant.RSA_DECRYPT)
    Response<RsaCipherData> rsaDecrypt(@RequestBody @Valid Request<RsaCipherParam> request);

    @Operation(summary = "RSA 加签", description = "@DaoDao 输入 RSA 私钥，加签")
    @PostExchange(url = SecurityConstant.RSA_SIGN)
    Response<RsaSignData> rsaSign(@RequestBody @Valid Request<RsaSignParam> request);

    @Operation(summary = "RSA 验签", description = "@DaoDao 输入 RSA 公钥，验签")
    @PostExchange(url = SecurityConstant.RSA_VERIFY)
    Response<RsaVerifyData> rsaVerify(@RequestBody @Valid Request<RsaVerifyParam> request);

    @Operation(summary = "RSA 生成密钥", description = "@DaoDao 生成指定密钥长度的 RSA 密钥对儿")
    @PostExchange(url = SecurityConstant.RSA_GENERATE_KEY)
    Response<RsaKeyData> rsaGenerateKey(@RequestBody @Valid Request<RsaKeyParam> request);

    @Operation(summary = "RSA 提取公钥", description = "@DaoDao 从 RSA 私钥中提取公钥")
    @PostExchange(url = SecurityConstant.RSA_EXTRACT_PUBLIC_KEY)
    Response<RsaKeyData> rsaExtractPublicKey(@RequestBody @Valid Request<RsaPrivateKeyParam> request);

}
